/////precompiled////////
#include "precompiled.h"
////////////////////////


#include "prs_FrmSplitterStyle.h"
using namespace prs;

// TRuleFrmVSplitterStyle /////////////////////////////////////////////////////

//
TRuleFrmVSplitterStyle::TRuleFrmVSplitterStyle(
  snt::text::TContext &Context,
  svl::TVariant &VParentNode,
  TRuleFrmStyleState &RStyleState
) 
:vParentNode(VParentNode)
,rStyleState(RStyleState)
{
  snt::TReturn Return;
  snt::TFVoid F;
  snt::text::TSequence T(Context);
  snt::text::TNumber N(Context);
  snt::text::TKeyword K(Context);
  prs::TFuncNewNodeIntoAttrOldChildren FNewNode;

  this->Name(GetClassName()).Local(vParentNode)
  | K.New("vSplitter") & FNewNode.New(VParentNode,TNodeFrmVSplitterStyle()) & T.New("(") & A.New()
  ;
  
  A.Name(GetClassName() + "[A]")
  | T.New("normal") & F.New(this,&TRuleFrmVSplitterStyle::FNormal) & rStyleState.New() & A.New()
  | T.New("down")   & F.New(this,&TRuleFrmVSplitterStyle::FDown)   & rStyleState.New() & A.New()
  
  | T.New("size") & T.New("=") 
    & N.NewClosure(this,&TRuleFrmVSplitterStyle::FSetSize) 
    & A.New()
  
  | T.New(")") & Return.New()
  ;

  //svl::TMessageModal(GetClassName() << "\r\n" << GetGraphInfo(""));
}

//
bool TRuleFrmVSplitterStyle::FSetSize(snt::text::TNumber::TFuncClosureDoEntryParams &Params)
{
  GetNode()->Style.Value.Weight = Params.Number.GetValue();
  return true;
}

// TRuleFrmHSplitterStyle /////////////////////////////////////////////////////

//
TRuleFrmHSplitterStyle::TRuleFrmHSplitterStyle(
  snt::text::TContext &Context,
  svl::TVariant &VParentNode,
  TRuleFrmStyleState &RStyleState
) 
:vParentNode(VParentNode)
,rStyleState(RStyleState)
{
  snt::TReturn Return;
  snt::TFVoid F;
  snt::text::TNumber N(Context);
  snt::text::TSequence T(Context);
  snt::text::TKeyword K(Context);
  prs::TFuncNewNodeIntoAttrOldChildren FNewNode;

  this->Name(GetClassName()).Local(vParentNode)
  | K.New("hSplitter") & FNewNode.New(VParentNode,TNodeFrmHSplitterStyle()) & T.New("(") & A.New()
  ;
  
  A.Name(GetClassName() + "[A]")
  | T.New("normal") & F.New(this,&TRuleFrmHSplitterStyle::FNormal) & rStyleState.New() & A.New()
  | T.New("down")   & F.New(this,&TRuleFrmHSplitterStyle::FDown)   & rStyleState.New() & A.New()
  
  | T.New("size") & T.New("=") 
    & N.NewClosure(this,&TRuleFrmHSplitterStyle::FSetSize) 
    & A.New()
  
  | T.New(")") & Return.New()
  ;

  //svl::TMessageModal(GetClassName() << "\r\n" << GetGraphInfo(""));
}

//
bool TRuleFrmHSplitterStyle::FSetSize(snt::text::TNumber::TFuncClosureDoEntryParams &Params)
{
  GetNode()->Style.Value.Weight = Params.Number.GetValue();
  return true;
}
